package com.txc.pay.pay.impl;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
import com.txc.pay.vo.OrderVo;
import org.springframework.stereotype.Service;

/**
 * @ClassName: AliJsapiPay
 * @Description: 支付宝jsapi支付
 * @Author: TXC
 * @Date: 2023-12-26 11:36
 **/
@Service
public class AliJsapiPay extends AliPay {

    @Override
    public String pay(OrderVo order) {
        aliConfig(order.getAccountId());
        AlipayTradePagePayResponse response;
        try {
            response = Factory.Payment.Page().pay(order.getTitle(), order.getId(), order.getPriceYuan(), "");
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        return response.getBody();
    }
}
